/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * WorldMap.java
 *
 * Created on May 8, 2009, 9:31:57 PM
 */

package DigimonAdventure.UserInterface;
import DigimonAdventure.DigimonAdventure;
import DigimonAdventure.MP3Player.MusicPlayer;
import javax.swing.ImageIcon;

/**
 *
 * @author Benz Louis
 */
public class WorldMap extends javax.swing.JFrame {
    private MusicPlayer bgm;
    private MusicPlayer bgm2;
    /** Creates new form WorldMap */
    public WorldMap() {
        initComponents();
        bgm = new MusicPlayer("/DigimonAdventure/Sound/World Map.mp3");
        bgm2 = new MusicPlayer("/DigimonAdventure/Sound/Stage 3.mp3");
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        DialogNotification = new javax.swing.JDialog();
        jPanel1 = new javax.swing.JPanel();
        Note = new javax.swing.JLabel();
        CmdOK = new javax.swing.JButton();
        OuterPanel = new javax.swing.JLayeredPane();
        WorldLayer = new javax.swing.JLayeredPane();
        CmdToStage1 = new javax.swing.JButton();
        CmdToStage2 = new javax.swing.JButton();
        CmdToStage3 = new javax.swing.JButton();
        CmdToCity = new javax.swing.JButton();
        BGWorld = new javax.swing.JLabel();
        CmdToInv = new javax.swing.JButton();
        CmdToDigiStat = new javax.swing.JButton();
        Countdown = new javax.swing.JLabel();
        jLabel63 = new javax.swing.JLabel();
        Money = new javax.swing.JLabel();
        jLabel61 = new javax.swing.JLabel();
        PlayerName = new javax.swing.JLabel();
        jLabel62 = new javax.swing.JLabel();
        DialogBox = new javax.swing.JScrollPane();
        IsiDialog = new javax.swing.JTextArea();
        PlayerFace = new javax.swing.JLabel();

        DialogNotification.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        DialogNotification.setAlwaysOnTop(true);
        DialogNotification.setMinimumSize(new java.awt.Dimension(400, 150));
        DialogNotification.setResizable(false);

        Note.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        Note.setText("Masukin note disini");

        CmdOK.setText("OK");
        CmdOK.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                CmdOKMouseClicked(evt);
            }
        });
        CmdOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CmdOKActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(Note, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(167, 167, 167)
                        .addComponent(CmdOK, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Note, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(CmdOK, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(128, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout DialogNotificationLayout = new javax.swing.GroupLayout(DialogNotification.getContentPane());
        DialogNotification.getContentPane().setLayout(DialogNotificationLayout);
        DialogNotificationLayout.setHorizontalGroup(
            DialogNotificationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(DialogNotificationLayout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        DialogNotificationLayout.setVerticalGroup(
            DialogNotificationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(DialogNotificationLayout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(18, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Digimon Adventure - DigiSphere");
        setAlwaysOnTop(true);
        setResizable(false);
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentHidden(java.awt.event.ComponentEvent evt) {
                formComponentHidden(evt);
            }
            public void componentShown(java.awt.event.ComponentEvent evt) {
                formComponentShown(evt);
            }
        });

        CmdToStage1.setFont(new java.awt.Font("Palatino Linotype", 1, 12));
        CmdToStage1.setForeground(new java.awt.Color(204, 0, 0));
        CmdToStage1.setBorderPainted(false);
        CmdToStage1.setContentAreaFilled(false);
        CmdToStage1.setFocusPainted(false);
        CmdToStage1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                CmdToStage1MouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                CmdToStage1MouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                CmdToStage1MouseExited(evt);
            }
        });
        CmdToStage1.setBounds(90, 430, 240, 50);
        WorldLayer.add(CmdToStage1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        CmdToStage2.setFont(new java.awt.Font("Palatino Linotype", 1, 12));
        CmdToStage2.setForeground(new java.awt.Color(255, 51, 0));
        CmdToStage2.setBorderPainted(false);
        CmdToStage2.setContentAreaFilled(false);
        CmdToStage2.setFocusPainted(false);
        CmdToStage2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                CmdToStage2MouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                CmdToStage2MouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                CmdToStage2MouseExited(evt);
            }
        });
        CmdToStage2.setBounds(470, 400, 200, 50);
        WorldLayer.add(CmdToStage2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        CmdToStage3.setFont(new java.awt.Font("Palatino Linotype", 1, 12));
        CmdToStage3.setForeground(new java.awt.Color(255, 0, 0));
        CmdToStage3.setBorderPainted(false);
        CmdToStage3.setContentAreaFilled(false);
        CmdToStage3.setFocusPainted(false);
        CmdToStage3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                CmdToStage3MouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                CmdToStage3MouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                CmdToStage3MouseExited(evt);
            }
        });
        CmdToStage3.setBounds(410, 230, 160, 50);
        WorldLayer.add(CmdToStage3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        CmdToCity.setFont(new java.awt.Font("Palatino Linotype", 1, 17));
        CmdToCity.setText("Return to City of Beginning");
        CmdToCity.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                CmdToCityMouseClicked(evt);
            }
        });
        CmdToCity.setBounds(20, 530, 250, 50);
        WorldLayer.add(CmdToCity, javax.swing.JLayeredPane.DEFAULT_LAYER);

        BGWorld.setIcon(new javax.swing.ImageIcon(getClass().getResource("/DigimonAdventure/Graphics/World Map.jpg"))); // NOI18N
        BGWorld.setBounds(0, 0, 800, 600);
        WorldLayer.add(BGWorld, javax.swing.JLayeredPane.DEFAULT_LAYER);

        WorldLayer.setBounds(0, 0, 800, 600);
        OuterPanel.add(WorldLayer, javax.swing.JLayeredPane.DEFAULT_LAYER);

        CmdToInv.setFont(new java.awt.Font("Tahoma", 0, 12));
        CmdToInv.setText("Inventory");
        CmdToInv.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                CmdToInvMouseClicked(evt);
            }
        });
        CmdToInv.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CmdToInvActionPerformed(evt);
            }
        });
        CmdToInv.setBounds(830, 60, 170, 25);
        OuterPanel.add(CmdToInv, javax.swing.JLayeredPane.DEFAULT_LAYER);

        CmdToDigiStat.setFont(new java.awt.Font("Tahoma", 0, 12));
        CmdToDigiStat.setText("Digimon Status");
        CmdToDigiStat.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                CmdToDigiStatMouseClicked(evt);
            }
        });
        CmdToDigiStat.setBounds(830, 20, 170, 25);
        OuterPanel.add(CmdToDigiStat, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Countdown.setFont(new java.awt.Font("Tahoma", 3, 11));
        Countdown.setForeground(new java.awt.Color(204, 0, 102));
        Countdown.setText("<Hours> : <Minutes> : <Seconds>");
        Countdown.setBounds(510, 720, 197, 14);
        OuterPanel.add(Countdown, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel63.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel63.setForeground(new java.awt.Color(204, 0, 102));
        jLabel63.setText("Doom's Countdown:");
        jLabel63.setBounds(470, 690, 143, 17);
        OuterPanel.add(jLabel63, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Money.setFont(new java.awt.Font("Tahoma", 1, 12));
        Money.setText(": <Player's Money> bits");
        Money.setBounds(520, 640, 200, 15);
        OuterPanel.add(Money, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel61.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel61.setText("Money");
        jLabel61.setBounds(470, 640, 36, 15);
        OuterPanel.add(jLabel61, javax.swing.JLayeredPane.DEFAULT_LAYER);

        PlayerName.setFont(new java.awt.Font("Tahoma", 1, 12));
        PlayerName.setText(": <Player's Name>");
        PlayerName.setBounds(520, 610, 200, 15);
        OuterPanel.add(PlayerName, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel62.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel62.setText("Name");
        jLabel62.setBounds(470, 610, 31, 15);
        OuterPanel.add(jLabel62, javax.swing.JLayeredPane.DEFAULT_LAYER);

        IsiDialog.setColumns(20);
        IsiDialog.setEditable(false);
        IsiDialog.setRows(5);
        IsiDialog.setText("---Digimon World Adventure II---\nClear the dungeons to save the Digital World!\nLevel 1: Forest of Temptation\nLevel 2: Wind's Corridor\nFinal level: Pinnacle of Chaos");
        DialogBox.setViewportView(IsiDialog);

        DialogBox.setBounds(10, 610, 450, 100);
        OuterPanel.add(DialogBox, javax.swing.JLayeredPane.DEFAULT_LAYER);

        PlayerFace.setIcon(new javax.swing.ImageIcon(getClass().getResource("/DigimonAdventure/Graphics/FaceM.gif"))); // NOI18N
        PlayerFace.setBounds(840, 520, 180, 225);
        OuterPanel.add(PlayerFace, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(OuterPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 1024, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(OuterPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 768, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void CmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CmdOKActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_CmdOKActionPerformed

    private void CmdOKMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CmdOKMouseClicked
        DialogNotification.setVisible(false);
}//GEN-LAST:event_CmdOKMouseClicked

    private void CmdToStage1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CmdToStage1MouseClicked
        this.setVisible(false);
        DigimonAdventure.stage1ui.setVisible(true);
}//GEN-LAST:event_CmdToStage1MouseClicked

    private void CmdToStage1MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CmdToStage1MouseEntered
        //ubah wujud cursor:
}//GEN-LAST:event_CmdToStage1MouseEntered

    private void CmdToStage1MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CmdToStage1MouseExited
        //balikin wujud cursor:
}//GEN-LAST:event_CmdToStage1MouseExited

    private void CmdToStage2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CmdToStage2MouseClicked
        if(DigimonAdventure.eventui.getEvent() < 2 && DigimonAdventure.event2ui.getEvent() < 2){
            Note.setText("Restricted!!! You have no access to this location...");
            DialogNotification.setVisible(true);
        }else{
            this.setVisible(false);
            DigimonAdventure.stage2ui.setVisible(true);
        }
}//GEN-LAST:event_CmdToStage2MouseClicked

    private void CmdToStage2MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CmdToStage2MouseEntered
        //ubah wujud cursor:
}//GEN-LAST:event_CmdToStage2MouseEntered

    private void CmdToStage2MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CmdToStage2MouseExited
        //balikin wujud cursor:
}//GEN-LAST:event_CmdToStage2MouseExited

    private void CmdToStage3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CmdToStage3MouseClicked
        if(DigimonAdventure.eventui.getEvent() < 4 && DigimonAdventure.event2ui.getEvent() < 4){
            Note.setText("Restricted!!! You have no access to this location...");
            DialogNotification.setVisible(true);
        }else if(DigimonAdventure.eventui.getEvent() == 4 && DigimonAdventure.event2ui.getEvent() != 4){
            this.setVisible(false);
            DigimonAdventure.eventui.setVisible(true);
        }else if(DigimonAdventure.event2ui.getEvent() == 4 && DigimonAdventure.eventui.getEvent() != 4){
            this.setVisible(false);
            DigimonAdventure.event2ui.setVisible(true);
        }
        else{
            this.setVisible(false);
            DigimonAdventure.stage3ui.setVisible(true);
        }
}//GEN-LAST:event_CmdToStage3MouseClicked

    private void CmdToStage3MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CmdToStage3MouseEntered
        //ubah wujud cursor:
}//GEN-LAST:event_CmdToStage3MouseEntered

    private void CmdToStage3MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CmdToStage3MouseExited
        //balikin wujud cursor:
}//GEN-LAST:event_CmdToStage3MouseExited

    private void CmdToCityMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CmdToCityMouseClicked
        if(DigimonAdventure.eventui.getEvent() == 3){
            this.setVisible(false);
            DigimonAdventure.eventui.setVisible(true);
        }else if(DigimonAdventure.event2ui.getEvent() == 3){
            this.setVisible(false);
            DigimonAdventure.event2ui.setVisible(true);
        }else{
        DigimonAdventure.kotaui.setVisible(true);
        this.setVisible(false);
        }
}//GEN-LAST:event_CmdToCityMouseClicked

    private void CmdToInvMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CmdToInvMouseClicked
        DigimonAdventure.inventoriui.setVisible(true);
}//GEN-LAST:event_CmdToInvMouseClicked

    private void CmdToDigiStatMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CmdToDigiStatMouseClicked
        DigimonAdventure.statusui.setVisible(true);
}//GEN-LAST:event_CmdToDigiStatMouseClicked

    private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
        BGWorld.setIcon(createImageIcon("/DigimonAdventure/Graphics/World Map.jpg", "Dunia-biasa"));
        if(DigimonAdventure.eventui.getEvent() < 4){
            new Thread(bgm,"lagu-peta-dunia").start();
        }else{
            new Thread(bgm2,"lagu-final").start();
            BGWorld.setIcon(createImageIcon("/DigimonAdventure/Graphics/Destroyed World.jpg", "Dunia Ancur"));
        }
        PlayerFace.setIcon(DigimonAdventure.pemain.getImageIcon());
        PlayerName.setText(": "+DigimonAdventure.pemain.getNama());
        Money.setText(": "+String.valueOf(DigimonAdventure.pemain.getBit())+" bits");

    }//GEN-LAST:event_formComponentShown

    private void formComponentHidden(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentHidden
        if(DigimonAdventure.eventui.getEvent() < 4){
            bgm.stopMusic();
        }else{
            bgm2.stopMusic();
        }
    }//GEN-LAST:event_formComponentHidden

    private void CmdToInvActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CmdToInvActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_CmdToInvActionPerformed

protected ImageIcon createImageIcon(String path, String description) {
	java.net.URL imgURL = getClass().getResource(path);
	if (imgURL != null) {
		return new ImageIcon(imgURL, description);
	} else {
		System.err.println("Couldn't find file: " + path);
		return null;
	}
}

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new WorldMap().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel BGWorld;
    private javax.swing.JButton CmdOK;
    private javax.swing.JButton CmdToCity;
    private javax.swing.JButton CmdToDigiStat;
    private javax.swing.JButton CmdToInv;
    private javax.swing.JButton CmdToStage1;
    private javax.swing.JButton CmdToStage2;
    private javax.swing.JButton CmdToStage3;
    private javax.swing.JLabel Countdown;
    private javax.swing.JScrollPane DialogBox;
    private javax.swing.JDialog DialogNotification;
    private javax.swing.JTextArea IsiDialog;
    private javax.swing.JLabel Money;
    private javax.swing.JLabel Note;
    private javax.swing.JLayeredPane OuterPanel;
    private javax.swing.JLabel PlayerFace;
    private javax.swing.JLabel PlayerName;
    private javax.swing.JLayeredPane WorldLayer;
    private javax.swing.JLabel jLabel61;
    private javax.swing.JLabel jLabel62;
    private javax.swing.JLabel jLabel63;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables

}
